#ifndef VIDEOGLWIDGET_H
#define VIDEOGLWIDGET_H

#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLWidget>
#include <QVideoFrame>
#include <QVideoSink>
#include <GL/gl.h>

/*
    继承了 QOpenGLWidget GUI类 和 QOpenGLFunctions接口类
    整体功能:
        实现了视频的OpenGL渲染绘制
*/

class VideoGLWidget : public QOpenGLWidget, protected QOpenGLFunctions {
    Q_OBJECT
public:
    VideoGLWidget(QWidget* parent = nullptr);
    ~VideoGLWidget() override;

    QVideoSink* mVideoSink;
protected:
    void initializeGL() override;
    void resizeGL(int width, int height) override;
    void paintGL() override;

private:
    GLuint textureId;
    QImage currentFrame;
    QOpenGLShaderProgram* program {nullptr};
};

#endif // VIDEOGLWIDGET_H
